'''
 This class represent an tree node with 
 pointer to left child (left), right child also called
 (right) and the parent node called (parent).
 
'''

class Node :
    
    def __init__(self, data):
        self.parent = None
        self.left = None
        self.right = None
        self.data = data
        
    def getParent(self):
        return self.parent
        
    def setParent(self, parent):
        self.parent = parent
        
    def getLeft(self):
        return self.left
        
    def setLeft(self, left):
        self.left = left
        
    def getRight(self):
        return self.right
    
    def setRight(self, right):
        self.right = right
        
    def getData(self):
        return self.data
        
    def setData(self, data):
        self.data = data
        
    def isRoot(self):
        if self.parent == None:
            return True
        else:
            return self.parent.isEmpty()
            
    def isLeaf(self):
        return self.left == None and self.right == None
        
    def hasOneChild(self):
        return self.left.isEmpty() and not self.right.isEmpty() or self.right.isEmpty() and not self.left.isEmpty()

    def isLeftChild(self):
        return self.data < self.parent.getData()

    def isRightChild(self):
        return self.data > self.parent.getData()

    def isEmpty(self):
        return self.data == None
    
    def equals(self, node):
        return self.data == node.getData()
    
    def __str__(self):
        return ("%s") % (self.data)